package org.spitter.core.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.springframework.format.annotation.DateTimeFormat;

@Entity
@Table(name = "spittles")
public class Spittle extends BaseEntity {
	private static final long serialVersionUID = 1L;

	@ManyToOne
	@JoinColumn(name = "spitter_id", nullable = false)
	private Spitter spitter;

	@Column(name = "`text`")
	@NotNull
	@Size(min = 1, max = 140, message="Your spittle message must be between 1 and 140 characters long.")
	private String text;

	@DateTimeFormat(pattern = "hh:mma d MMM, YYYY")
	@Column(name = "whenCol")
	private Date when;

	public Spittle() {
	}

	public Spittle(Spitter spitter, String text, Date when) {
		super();
		this.spitter = spitter;
		this.text = text;
		this.when = when;
	}

	public String getText() {
		return this.text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Date getWhen() {
		return this.when;
	}

	public void setWhen(Date when) {
		this.when = when;
	}

	public Spitter getSpitter() {
		return this.spitter;
	}

	public void setSpitter(Spitter spitter) {
		this.spitter = spitter;
	}

	
	// // plumbing
	// @Override
	// public boolean equals(Object obj) {
	// return reflectionEquals(this, obj);
	// }
	//
	// @Override
	// public int hashCode() {
	// return reflectionHashCode(this);
	// }
	//
	// @Override
	// public String toString() {
	// return reflectionToString(this);
	// }
}
